  #include<system.h>

void APP_NETWORKstartdone(error_t);
void APP_NETWORKsendDone(error_t);
message_t* APP_NETWORKrecv(message_t*, uint8_t*, uint16_t);

message_t app_payload;
message_t* app_ptr;


uint8_t i;


void module_init(void);

void APP_booted(void) {
	module_init();
	
	
	NETWORK_reg(APP_NETWORKstartdone, APP_NETWORKsendDone, APP_NETWORKrecv);
	NETWORK_start(); 
	

}

void module_init(){
	SERIAL0_init();
	XBEE_init();
	NETWORK_init();
	LED_init();
	
	
}

void APP_NETWORKstartdone(error_t error){
    
	uint8_t data[]="hello";
    
	for (i=0;i<sizeof(data);i++){
		app_payload.payload[i] = data[i];
	}

	app_ptr = &app_payload;


    NETWORK_send(NET_DEST_ADD,app_ptr,sizeof(data),1);
	
 



}

void APP_NETWORKsendDone(error_t error){

	LED3_toggle();

	uint8_t data[]="hello";
    
	for (i=0;i<sizeof(data);i++){
		app_payload.payload[i] = data[i];
	}

	app_ptr = &app_payload;


   NETWORK_send(NET_DEST_ADD,app_ptr,sizeof(data),1);
   

}

message_t* APP_NETWORKrecv(message_t* apiframe, uint8_t* payload, uint16_t source){
 
 
  return apiframe;
}